package logic

import (
	"ball/models/mysql"
	"context"

	"ball/ballrpc/ballrpc"
	"ball/ballrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type CommentListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCommentListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CommentListLogic {
	return &CommentListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 评论展示
func (l *CommentListLogic) CommentList(in *ballrpc.CommentListRequest) (*ballrpc.CommentListesponse, error) {
	// todo: add your logic here and delete this line
	var post []mysql.Post
	mysql.DB.Debug().Find(&post)
	var TopList []*ballrpc.CommentList
	for _, m := range post {
		list := ballrpc.CommentList{
			Title: m.Title,
			Desc:  m.Desc,
		}
		TopList = append(TopList, &list)
	}
	return &ballrpc.CommentListesponse{
		List: TopList,
	}, nil
}
